package com.ljx.controller;

import com.ljx.common.ResponseResult;
import com.ljx.service.FileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author 李捷禧
 * Date: 2023/4/21
 * ClassName: UploadController
 */
@RestController
public class UploadController {

    @Autowired
    private FileService fileService;
    /**
     * 文件上传
     */
    @PostMapping("/upload")
    public ResponseResult upload(@RequestParam(value = "img", required = false) MultipartFile file) {
        String upload = fileService.upload(file);
        return ResponseResult.okResult(upload);
    }
}
